import { reqHospitalDepartment, reqHospitalDetail } from "@/apis/hospital/index";
import type { DeparmentResponseData, HosPitalDetail, HospitalDetail } from "@/apis/hospital/type";
import { defineStore } from "pinia";
import { DetailState } from "./interface";

const useDetailStore = defineStore('Detail', {
  state: ():DetailState => {
    return {
      hospitalInfo: ({} as HosPitalDetail),
      deparmentArr: []
    }
  },
  actions: {
    //获取医院详情  
    async getHospital(hoscode: string) {
      const res: HospitalDetail = await reqHospitalDetail(hoscode)
      if (res.code == 200) {
        this.hospitalInfo = res.data
      }
    },
    // 获取科室信息
    async getDepartment(hoscode: string) {
      const res: DeparmentResponseData = await reqHospitalDepartment(hoscode)
      if (res.code == 200) {
        this.deparmentArr = res.data
      }
    }
  },
  getters: {

  }
})

export default useDetailStore